﻿using JuCheap.Store.DataService;
using JuCheap.Store.DataService.Entity;
using JuCheap.Store.IService.Models;
using JuCheap.Store.IService.Service;
using System.Threading.Tasks;

namespace JuCheap.Store.Service
{
    public class StoreSaveService : IStoreSaveService
    {
        private readonly IBaseDataService<StoreRecordEntity> _baseDataService;

        public StoreSaveService(IBaseDataService<StoreRecordEntity> baseDataService)
        {
            _baseDataService = baseDataService;
        }

        /// <summary>
        /// 保存入库信息
        /// </summary>
        /// <param name="req">入库信息</param>
        /// <returns>入库流水Id</returns>
        public async Task<string> SaveAsync(StoreSaveDTO req)
        {
            var entity = new StoreRecordEntity
            {
                ProjectNo = req.ProjectNo,
                ProjectPlace = req.ProjectPlace,
                StoreNo = req.StoreNo,
                Number = req.Number
            };
            return await _baseDataService.InsertAsync(entity);
        }
    }
}
